﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VirtualBank
{
    public  class Account
    {
        public int Id { get; private set; }
        public string OwnerName { get; private set; }
        public string Password { get; private set; }
        public double Balance { get; protected set; }

        public Account() {
        }
        public Account(int id, string name, string password, double balance)
        {
            this.Id = id;
            this.OwnerName = name;
            this.Password = password;
            this.Balance = balance;
        }

        //重置账户信息
        public void resetInform(string Name,String Password) {
            this.OwnerName = Name;
            this.Password = Password;
        }

        //存款
        public  void Deposit(double amount)
        {
            if (amount > 0)
                Balance += amount;
            else
                throw new IllegalException("不合法的存款金额");
        }
        //取款
        public virtual void withdraw(double amount)
        {
            if (amount > 0 && amount <= Balance)
                Balance -= amount;
            else
                throw new IllegalException("不合法的取款金额");
        }
    }
}
